<?php

namespace App\Http\Requests\Backend\Setting;

use Illuminate\Foundation\Http\FormRequest;

class SettingDocumentRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $method = $this->method();
        switch ($method){
            case 'POST':
                return [
                    'type' => 'bail|required|in:1,2,3,4',
                    'document_name' => 'required',
                    'document_url' => 'required',
                ];
                break;
            case "PUT":
                return [
//                    'channel_code' => 'required',
                ];
                break;
        }
    }

    public function messages()
    {
        return [
            'type.required' => '请传递类型',
            'type.in' => '类型传递错误',
            'document_name.required' => '请传递文档名称',
            'document_url.required' => '请传递文档路径',
            'channel_code.required' => '请传递资方编号'

        ];
    }
}
